package Network.homework;

import java.io.IOException;
import java.net.DatagramSocket;
import java.net.SocketException;
import java.util.HashMap;

public class UdpDirectServer extends UdpEchoServer{
     private HashMap<String,String> hashMap=new HashMap<>();
    public UdpDirectServer(int port) throws SocketException {
        super(port);
        hashMap.put("cat","小猫");
        hashMap.put("dog","小狗");
        hashMap.put("pig","小猪");
        hashMap.put("flag","小鸟");
    }

    @Override
    public String process(String request) {
        return hashMap.getOrDefault(request,"要查找的单词不存在");
    }

    public static void main(String[] args) throws IOException {
        UdpDirectServer udpDirectServer = new UdpDirectServer(9090);
        udpDirectServer.start();
    }
}
